<template>
  <div v-for="item in orderList" :key="item.order_id">
    <div class="order-item">
      <div class="item-header">
        <div class="date">{{ item.pay_time }}</div>
        <div class="send">{{ item.state_text }}</div>
      </div>
      <div class="good" v-for="good in item.goods" :key="good.goods_id">
        <img :src="good.goods_image" alt="" />
        <div class="good-name">
          {{ good.goods_name }}
        </div>
        <div class="good-price">
          <div>￥{{ good.goods_pay_price }}</div>
          <span class="count"> {{ good.total_num }}</span>
        </div>
      </div>
      <div class="total">
        共{{ item.total_num }} 件商品，总金额￥{{ item.order_price }}
      </div>
      <div class="actions">
        <div v-if="item.order_status === 10">
          <span v-if="item.pay_status === 10">立刻付款</span>
          <span v-else-if="item.delivery_status === 10">申请取消</span>
          <span
            v-else-if="
              item.delivery_status === 20 || item.delivery_status === 30
            "
            >确认收货</span
          >
        </div>
        <div v-if="item.order_status === 30">
          <span>评价</span>
        </div>
      </div>
      <div class="space"></div>
    </div>
  </div>
</template>
<script>
export default {
  name: 'MyOrderItem',
  props: {
    orderList: {
      type: Array
    }
  }
}
</script>

<style scoped>
.order-item {
  margin-bottom: 10px;
  box-shadow: 0 0.5px 2px 0 rgba(0, 0, 0, 0.05);
  border-radius: 8px;
  color: #333;
  font-size: 13px;
  .item-header {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    .date {
      font-size: 15px;
    }
    .send {
      color: red;
      margin-left: auto;
    }
  }
  .good {
    display: flex;
    margin-bottom: 20px;
    img {
      width: 80px;
      height: 80px;
      margin-right: 25px;
    }
    .good-name {
      width: 150px;
      line-height: 1.5; /* 行高 */
      max-height: 3em; /* 两行文本的高度 */
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2; /* 定义要显示的行数 */
      overflow: hidden;
      text-overflow: ellipsis; /* 溢出部分用省略号表示 */
    }
    .good-price {
      margin-left: auto;
      color: rgb(203, 200, 201);
      text-align: end;
      .count::before {
        margin-right: 4px;
        content: '×';
      }
    }
  }
  .total {
    text-align: right;
    margin-bottom: 10px;
  }
  .cancel {
    padding: 5px 0;
    margin-left: auto;
    width: 100px;
    text-align: right;
    color: rgb(174, 166, 169);
  }
  .actions {
    text-align: right;
    span {
      display: inline-block;
      height: 28px;
      line-height: 28px;
      color: #383838;
      border: 0.5px solid #a8a8a8;
      font-size: 14px;
      padding: 0 15px;
      border-radius: 5px;
      margin: 10px 0;
    }
  }
  .space {
    width: 100%;
    height: 10px;
    background-color: rgb(250, 250, 250);
  }
}
</style>
